#ifndef __INPUTHANDLER_H__
#define __INPUTHANDLER_H__

#include <AGTRenderSystem/RenderManager.h>
#include "InputManager.h"
#include "OIS/OISEvents.h"
#include "OIS/OISInputManager.h"
#include "OIS/OISKeyboard.h"
#include "OIS/OISMouse.h"
#include "OIS/OISJoystick.h"

#include <string>

using namespace std;


class InputManager;
class InputHandler :
					public OIS::MouseListener,
					public OIS::KeyListener,
					public OIS::JoyStickListener
{
protected:	// Attributes
	string							m_sName;
	OIS::InputManager				*m_pInputMgr;
	OIS::Keyboard					*m_pKeyboard;
	OIS::Mouse						*m_pMouse;
	OIS::JoyStick					*m_pJoystick;
	unsigned long					m_hWnd;

	bool							m_bOn;

	//TODO: Add pointer reference attribute to XInput controller

public:	// Functions
	InputHandler();
	InputHandler(string name);
	~InputHandler();

	bool isOn(void){ return m_bOn; }
	void switchOff(void){ m_bOn = false; }
	void switchOn(void){ m_bOn = true; }
	string getName(void){ return m_sName; }
	void setName(string name){ m_sName = name; }
	virtual void capture(void);


	// Handling presses and releases
	virtual bool updateKey()=0;
	virtual bool updateMouse()=0;
	virtual bool updateJoy()=0;

	// ------- Functions for explicit presses and release
	// Mouse Listener functions
	virtual bool mouseMoved(const OIS::MouseEvent &evt)=0;
	virtual bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID)=0;
	virtual bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID)=0;

	// Keyboard listener functions
	virtual bool keyPressed(const OIS::KeyEvent &evt)=0;
	virtual bool keyReleased(const OIS::KeyEvent &evt)=0;

	// Joystick listener functions
	virtual bool buttonPressed(const OIS::JoyStickEvent &evt, int index)=0;
	virtual bool buttonReleased(const OIS::JoyStickEvent &evt, int index)=0;
	virtual bool axisMoved(const OIS::JoyStickEvent &evt, int index)=0;
	virtual bool povMoved(const OIS::JoyStickEvent &evt, int index)=0;
};

#endif